package com.example.demo.commons.core.codec;

import org.apache.commons.codec.binary.Base64;

/**
 * <p> Base64 </p>
 *
 * @author tanyunpeng
 * @date 2021/11/18
 */
public class Base64Utils {

    /**
     * 编码
     */
    public static String encrypt(String plainText) {
        byte[] b = plainText.getBytes();
        return Base64.encodeBase64URLSafeString(b);
    }

    /**
     * 解码
     */
    public static String decrypt(String cipherText) {
        byte[] b = cipherText.getBytes();
        Base64 base64 = new Base64();
        b = base64.decode(b);
        return new String(b);
    }
}